<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Migration_CreateTable_UserActivation extends CI_Migration
{
    public function up()
    {
        $this->dbforge->add_field('id');
        $this->dbforge->add_field(array(
            'user_id'          => array('type' => 'INT', 'constraint' => '9'),
            'activation_code'  => array('type' => 'VARCHAR', 'constraint' => '10',),
            'time_of_validity' => array('type' => 'DATETIME', 'null' => TRUE,),
        ));
        $this->dbforge->create_table('user_activation');
        $this->db->simple_query('ALTER TABLE user_activation ADD UNIQUE (user_id)');
    }

    public function down()
    {
        $this->dbforge->drop_table('user_activation');
    }
} 